/**
 * 
 */

var datePicker;
var dateCount = 0;

//initialization
$(function() {
//	datePicker = $("#datepicker").multiDatesPicker({
//		numberOfMonths : 2,
//		minDate:0, //prevent select past day
//		maxDate:"+2Y",
//		mode: {
//			modeName: 'daysRange',
//			options : {autoselectRange: [0,2]}
//		}
//	});

	$('#addButton').bind('click', addCandidateDate);
	
	//$('.btn').button();
	$('#1d').button('toggle');
});

//Event handlers
function addCandidateDate() {
	var startDate = datePicker.datepicker("getDate");
	dateCount++;
	$('#dateListBody')
	.append(
			"<tr>"
			+ "<td>"
			+ $.datepicker.formatDate("yy-mm-dd",startDate)
			+ "</td>"
			+ "<td><div id='calendarDisplay"+dateCount+"''/></td>"
			+ "<td><input type='button' value='刪除' class='btn' onclick='deleteRow(this)' /></td></tr>");
	$("#calendarDisplay"+dateCount).datepicker({
		minDate:0, //prevent select past day
		maxDate:"+2Y",
		defaultDate:startDate
	});
}
function deleteRow(deleteButton){
	$(deleteButton).parent().parent().remove()

}